<?php


namespace app\index\controller;


use app\BaseController;
use app\index\business\enterpriseBus;
use think\facade\View;

class Enterprise extends BaseController
{
    public function index(){
        View::assign('title','企业库');
        return View::fetch();
    }
    public function getMemberPageWhere(){
        $where = $this->request->param('where');
        $where['status'] = 1;
        $paging = $this->request->param('paging');
        $title = $this->request->param('title');
        $address = $this->request->param('address');
        $trade_name = $this->request->param('tradeName');
        $consignorBus = new enterpriseBus();
        try {
            $res = $consignorBus->getMemberPageWhereBus($where,$paging,$title,$address,$trade_name);
        } catch (\Exception $exception){
            return show(config('status.error'),$exception->getMessage());
        }
        return show(config('status.success'),'查询成功',$res);
    }
    public function detail(){
        $id = $this->request->param('id');
        View::assign('id',$id);
        View::assign('title','详情');
        return View::fetch();
    }

    /**获取会员的详情
     * @return \think\response\Json
     */
    public function getDetail(){
        $id = $this->request->param('id');
        $member_id = $this->request->param('member_id');
        $consignorBus = new enterpriseBus();
        try {
            $res = $consignorBus->getDetailBus($id,$member_id);
        } catch (\Exception $exception){
            return show(config('status.error'),$exception->getMessage());
        }
        return show(config('status.success'),'查询成功',$res);
    }

    public function pushFacilitator(){
        $member_id = $this->request->param('member_id');
        $member_info_id=$this->request->param('member_info_id');
        $member_info_name=$this->request->param('member_info_name');
        if(empty($member_id)||empty($member_info_id)){
            return show(config('status.error'),'申请信息错误');
        }
        $consignorBus = new enterpriseBus();
        try {
            $res = $consignorBus->pushFacilitatorBus($member_id,$member_info_id,$member_info_name);
        } catch (\Exception $exception){
            return show(config('status.error'),$exception->getMessage());
        }
        return show(config('status.success'),'申请成功等待审核...',$res);
    }
    public function isApplyAdd(){
        $member_id = $this->request->param('member_id');
        $member_info_id=$this->request->param('member_info_id');
        $consignorBus = new enterpriseBus();
        try {
            $res = $consignorBus->isApplyAddBus($member_id,$member_info_id);
        } catch (\Exception $exception){
            return show(config('status.error'),$exception->getMessage());
        }
        return show(config('status.success'),'正在查询',$res);
    }

}